home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Presentations / Presentations ’88 / Fritz Proceedings stuff / setLDEF.c < prev   
C/C++ Source or Header  |  1988-04-02  |  2KB  |  73 lines

  1. #include <QuickDraw.h>
  2. #include <Lists.h>
  3. #include <Fonts.h>
  4.  
  5. #define HiliteMode        (*(unsigned char *)0x938)
  6. #define hiliteBit        7                /* flag bit in HiliteMode (lowMem flag) */
  7.  
  8. typedef struct {
  9.     short        baseLine;
  10.     RgnHandle    cellRgn;
  11.     }    LRefCon, *LRCPtr, **LRCHandle;
  12.  
  13. #define LBaseLine(list)    ((*(LRCHandle)(*list)->refCon)->baseLine)
  14. #define LCellRgn(list)    ((*(LRCHandle)(*list)->refCon)->cellRgn)
  15.  
  16. pascal void main(lMessage, lSelect, lRect, lCell,
  17.                  lDataOffset, lDataLen, lHandle)
  18. short        lMessage;
  19. Boolean        lSelect;
  20. Rect        *lRect;
  21. Cell        lCell;
  22. short        lDataOffset,
  23.             lDataLen;
  24. ListHandle    lHandle;
  25. {
  26.     void        Initialize(),
  27.                 Draw();
  28.     RgnHandle    drawRgn,
  29.                 temp;
  30.             
  31.     switch (lMessage)    {
  32.         case lInitMsg:        Initialize(lHandle);
  33.                             break;
  34.         case lDrawMsg:        if (lDataLen > 0) {
  35.                                 Draw(lDataOffset, LBaseLine(lHandle),
  36.                                                 (*lHandle)->cells, lRect,
  37.                                                 (*lHandle)->cellSize);
  38.                                 drawRgn = LCellRgn(lHandle);
  39.                                 RectRgn(temp = NewRgn(), lRect);
  40.                                 UnionRgn(temp, drawRgn, drawRgn);
  41.                                 DisposeRgn(temp);
  42.                                 if (!lSelect)
  43.                                     break;
  44.                                 }
  45.                             else
  46.                                 break;
  47.                             /**********************
  48.                              *    NOTE TRICK HERE
  49.                              *    Will fall thru if
  50.                              *    the cell is to be
  51.                              *    drawn "selected."
  52.                              **********************/
  53.         case lHiliteMsg:    HiliteMode &= 0x7F;        /*    Don't we have to sense CQD?    */
  54.                             InvertRect(lRect);
  55.                             break;
  56.         default:            break;
  57.         }
  58.     }
  59.  
  60. void Initialize(lHandle)
  61. ListHandle    lHandle;
  62. {
  63.     FontInfo    theFont;
  64.     LRefCon        theRef;
  65.     
  66.     GetFontInfo(&theFont);
  67.     theRef.baseLine = theFont.ascent + theFont.leading;
  68.     theRef.cellRgn = NewRgn();
  69.     HLock(lHandle);
  70.     PtrToHand(&theRef, &(*lHandle)->refCon, sizeof(LRefCon));
  71.     HUnlock(lHandle);
  72.     }
  73.